home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / mcu11 / gloade9a.arc / GLOADE9.BAS < prev    next >
BASIC Source File  |  1991-08-13  |  42KB  |  1,340 lines

  1.  
  2. '*****************************************************************************
  3. '****************                                             ****************
  4. '****************              E9 Gang Programmer             ****************
  5. '****************                                             ****************
  6. '*****************************************************************************
  7. '*                                                                           *
  8. '* Program Name: GLOADE9.BAS                                                 *
  9. '* Revision: 0.03                                                            *
  10. '* Date: 3/17/91                                                             *
  11. '* Written By: Robert Chretien                                               *
  12. '*             Motorola MCU Applications                                     *
  13. '* Compiled Under: Microsoft QuickBASIC Version 4.00                         *
  14. '*                                                                           *
  15. '* Program Description:                                                      *
  16. '*                                                                           *
  17. '*                                                                           *
  18. '*                                                                           *
  19. '*                                                                           *
  20. '*                                                                           *
  21. '*****************************************************************************
  22. '*                                                                           *
  23. '* Revision Descriptions:                                                    *
  24. '* 1. Rev 0.03: Original program. Modified from GLOADD3.BAS Rev 0.03.        *
  25. '*              Added routines to program, verify, and compare EEProm.       *
  26. '*                                                                           *
  27. '*                                                                           *
  28. '*                                                                           *
  29. '*****************************************************************************
  30. '*****************************************************************************
  31. '
  32. '
  33. '
  34. Initialization:
  35.     DIM RAMLoadByte(300)
  36.     DIM GoodBoard(10)
  37.     Debug = 0
  38.     HexConvert$ = "0123456789ABCDEF"
  39.     OPEN "CONFIG.PE9" FOR INPUT AS #1
  40.     INPUT #1, ComPort, ResponseTime
  41.     CLOSE
  42.     ON ERROR GOTO ErrorTrap
  43. PickMainOption:
  44.     CLS
  45.     LOCATE 4, 16
  46.     PRINT "Motorola MC68HC711E9 GangProgramming Software"
  47.     LOCATE 5, 16
  48.     PRINT "                 Version 0.03"
  49.     LOCATE 9, 10
  50.     PRINT "1) EPROM Blank Check"
  51.     LOCATE 10, 10
  52.     PRINT "2) Program and Verify EPROM and/or EEPROM"
  53.     LOCATE 11, 10
  54.     PRINT "3) Program and Verify multiple sets of boards with same program"
  55.     LOCATE 12, 10
  56.     PRINT "4) Verify EPROM and/or EEPROM Contents"
  57.     LOCATE 13, 10
  58.     PRINT "5) Test and Debug"
  59.     LOCATE 15, 10
  60.     PRINT "S) For System Configuration"
  61.     LOCATE 16, 10
  62.     PRINT "X) To EXIT program"
  63.     LOCATE 18, 10
  64.     INPUT "Enter number of desired selection"; OptionChoice$
  65.     IF OptionChoice$ = "X" OR OptionChoice$ = "x" THEN GOSUB ThatsAll
  66.     IF OptionChoice$ = "S" OR OptionChoice$ = "s" THEN
  67.        GOSUB Config
  68.        GOTO PickMainOption
  69.     END IF
  70.     OptionChoice = VAL(OptionChoice$)
  71.     NoBoards = 8
  72.     PartType$ = "E9"
  73.     RAMAddressLow$ = "0000": RAMAddressHigh$ = "01FF"
  74.     EEPromAddressLow$ = "B600": EEPromAddress$ = "B7FF"
  75.     EPromAddressLow$ = "D000": EPromAddressHigh$ = "FFFF"
  76.     MSBBootAddress$ = "BF": LSBBootAddress$ = "4D"
  77.     IF OptionChoice = 0 THEN GOSUB ThatsAll
  78.     IF OptionChoice = 1 THEN GOSUB Check4Blank
  79.     IF OptionChoice = 2 THEN GOSUB ProgProm
  80. Choice3:
  81.     IF OptionChoice = 3 THEN
  82.        IF RepeatFileName$ = "" THEN
  83. RepeatFileName1:
  84.           CLS
  85.           LOCATE 10, 1
  86.           INPUT "Enter file name to program into HC11"; RepeatFileName$
  87.           IF RepeatFileName$ = "" THEN GOTO RepeatFileName1
  88.        END IF
  89.        GOSUB ProgProm
  90.     END IF
  91.     IF OptionChoice = 3 THEN
  92.        PRINT "Change parts and hit ENTER when ready to program again"
  93.        INPUT "Or enter X to return to main menu"; CR$
  94.        IF CR$ = "X" OR CR$ = "x" THEN
  95.           RepeatFileName$ = ""
  96.           GOTO PickMainOption
  97.        END IF
  98.        GOTO Choice3
  99.     END IF
  100.     IF OptionChoice = 4 THEN GOSUB VerProm
  101.     IF OptionChoice = 5 THEN
  102. DeBugChoice:
  103.        CLS
  104.        LOCATE 4, 18
  105.        PRINT "MC68HC711E9 Board Test and Debug"
  106.        LOCATE 8, 10
  107.        PRINT "1) Test PC to E9 board connection."
  108.        LOCATE 9, 10
  109.        PRINT "2) Load Test Program into RAM and Execute"
  110.        LOCATE 10, 10
  111.        PRINT "3) Program EPROM with Test Program and Execute"
  112.        LOCATE 11, 10
  113.        PRINT "4) Program EEPROM with Test Program and Execute"
  114.        LOCATE 12, 10
  115.        PRINT "5) Compare file to HC11 memory"
  116.        LOCATE 15, 10
  117.        PRINT "X) Return to main menu"
  118.        LOCATE 17, 10
  119.        INPUT "Enter number of desired selection"; DeBugChoice$
  120.        IF DeBugChoice$ = "X" OR DeBugChoice$ = "x" THEN GOTO PickMainOption
  121.        IF DeBugChoice$ = "1" THEN GOSUB CheckConnection
  122.        IF DeBugChoice$ = "2" THEN GOSUB TestWithRAM
  123.        IF DeBugChoice$ = "3" THEN GOSUB TestProgProm
  124.        IF DeBugChoice$ = "4" THEN GOSUB TestProgEEProm
  125.        IF DeBugChoice$ = "5" THEN GOSUB VerProm
  126.        GOTO DeBugChoice
  127.     END IF
  128.     GOTO PickMainOption
  129.  
  130. WhatNext:
  131.        ' download finished. what now?
  132. ThatsAll:
  133.     CLOSE
  134.     END
  135.  
  136.  
  137. '*****************************************************************************
  138. '*****************************************************************************
  139. '*                                                                           *
  140. '*                     First level subroutines                               *
  141. '*                                                                           *
  142. '*****************************************************************************
  143. '*
  144. '*
  145. '*
  146. Config:
  147.     CLS
  148.     LOCATE 3, 10
  149.     PRINT "Configuration Menu"
  150.     LOCATE 6, 5
  151.     PRINT "Enter the number corresponding to the serial port in use."
  152.     LOCATE 8, 5
  153.     PRINT "1) COM1"
  154.     LOCATE 9, 5
  155.     PRINT "2) COM2"
  156.     LOCATE 11, 5
  157.     INPUT "HC711E9 board connected to serial port"; ComPort
  158.     IF ComPort = 0 THEN GOTO Config
  159.     IF ComPort > 2 THEN GOTO Config
  160.     LOCATE 14, 5
  161.     PRINT "Enter the number of the PC description closest to your machine"
  162.     PRINT "       NOTE: If in doubt pick a slower machine"
  163. MachineType:
  164.     LOCATE 16, 5
  165.     PRINT "1) Slow PC/XT (Non-Turbo)"
  166.     LOCATE 17, 5
  167.     PRINT "2) Fast PC/XT (Turbo)"
  168.     LOCATE 18, 5
  169.     PRINT "3) Slow PC/AT/XT-286 (6MHz to 10MHz)"
  170.     LOCATE 19, 5
  171.     PRINT "4) Medium Speed PC/AT/XT-286 (12MHz to 16MHz)"
  172.     LOCATE 20, 5
  173.     PRINT "5) Fast PC/AT/XT-286 (Faster than 16MHz)"
  174.     LOCATE 21, 5
  175.     PRINT "6) 386 Machines"
  176.     LOCATE 23, 5
  177.     INPUT "Machine Type"; Machine
  178.     IF Machine = 0 THEN GOTO MachineType
  179.     IF Machine = 1 THEN ResponseTime = 100
  180.     IF Machine = 2 THEN ResponseTime = 200
  181.     IF Machine = 3 THEN ResponseTime = 400
  182.     IF Machine = 4 THEN ResponseTime = 500
  183.     IF Machine = 5 THEN ResponseTime = 600
  184.     IF Machine = 6 THEN ResponseTime = 800
  185.     IF Machine > 6 THEN GOTO MachineType
  186.     INPUT "Is the above correct"; CR$
  187.     IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO Config
  188.     INPUT "Save configuration to disk"; CR$
  189.     IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO ConfigDone
  190.     OPEN "CONFIG.PE9" FOR OUTPUT AS #1
  191.     PRINT #1, ComPort, ResponseTime
  192.     CLOSE
  193. ConfigDone:
  194.     RETURN
  195. '*
  196. '*
  197. '*
  198. Check4Blank:
  199.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 1
  200.     CheckSum = 0: Verify = 0: TalkAddress = 8
  201.     Filename$ = "GBlankE9.MX"
  202.     CLS
  203.     LOCATE 1, 1
  204.     PRINT "Downloading code into RAM for blank checking."
  205.     GOSUB CheckFile
  206.     GOSUB ConvertFile4RAM
  207.     GOSUB RAMSendFile
  208.     GOSUB PollAfterBootLoad
  209.     CLS
  210.     PRINT "Board Status:"
  211.     PRINT
  212.     FOR I = 1 TO 8
  213.     PRINT "Board "; I - 1
  214.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  215.     IF GoodBoard(I) = 1 THEN PRINT "Part verified as blank."
  216.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  217.     IF GoodBoard(I) = 3 THEN PRINT "Part NOT blank."
  218.     NEXT I
  219.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  220.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  221.     PRINT #1, CHR$(value);
  222.     CLOSE #1
  223.     PRINT : PRINT
  224.     IF TalkAddress = 8 THEN
  225.        PRINT "No boards are responding."
  226.        PRINT "Reset the HC11."
  227.     END IF
  228.     INPUT "Hit ENTER to continue"; CR$
  229.     RETURN
  230.  
  231. ProgProm:
  232.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  233.     CheckSum = 5: Verify = 0
  234.     Filename$ = "GPROGE9.MX"
  235.     CLS
  236.     LOCATE 1, 1
  237.     PRINT "Downloading code into RAM for PROM programming."
  238.     GOSUB CheckFile
  239.     GOSUB ConvertFile4RAM
  240.     GOSUB RAMSendFile
  241.     GOSUB PollAfterBootLoad
  242.  
  243.     CLS
  244.     PRINT "Board Status:"
  245.     PRINT
  246.     FOR I = 1 TO 8
  247.     PRINT "Board "; I - 1
  248.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  249.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  250.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  251.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  252.     NEXT I
  253.     BootLoad = 0
  254.     LOCATE 21, 1
  255.     IF TalkAddress = 8 THEN
  256.        PRINT "No boards are responding."
  257.        PRINT "Reset the HC11."
  258.        CLOSE
  259.        INPUT "Hit RETURN to Continue."; CR$
  260.        GOTO PickMainOption
  261.     ELSE
  262.        PRINT "RAM ready to program PROM."
  263.        IF OptionChoice = 3 THEN
  264.           Filename$ = RepeatFileName$
  265.           GOTO Option3
  266.        END IF
  267. Filename1:
  268.        LOCATE 23, 1
  269.        PRINT "Or reset the HC11 then enter X to return to main menu."
  270.        LOCATE 22, 1
  271.        INPUT "Enter file to be downloaded into PROM"; Filename$
  272.        IF Filename$ = "" THEN GOTO Filename1
  273.        IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
  274.     END IF
  275. Option3:
  276.     GOSUB CheckFile
  277.     GOSUB SendFile
  278.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  279.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  280.     PRINT #1, CHR$(value);
  281.     CLOSE #1
  282.     CLS
  283.     PRINT "PROM has been programmed."
  284.     CLOSE #2
  285.     TempFileName$ = Filename$
  286.     GOSUB VerProm
  287.     RETURN
  288.  
  289. VerProm:
  290.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  291.     CheckSum = 5: Verify = 1
  292.     Filename$ = "GVERE9.MX"
  293.     CLS
  294.     LOCATE 1, 1
  295.     PRINT "Downloading code into RAM for PROM verification."
  296.     GOSUB CheckFile
  297.     GOSUB ConvertFile4RAM
  298.     GOSUB RAMSendFile
  299.     GOSUB PollAfterBootLoad
  300.  
  301.     CLS
  302.     PRINT "Board Status:"
  303.     PRINT
  304.     FOR I = 1 TO 8
  305.     PRINT "Board "; I - 1
  306.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  307.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  308.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  309.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  310.     NEXT I
  311.     BootLoad = 0
  312.     IF OptionChoice = 2 OR OptionChoice = 3 OR DeBugChoice$ = "3" OR DeBugChoice$ = "4" THEN
  313.        Filename$ = TempFileName$
  314.     ELSE
  315.        IF TalkAddress = 8 THEN
  316.           LOCATE 22, 1
  317.           PRINT "No boards are responding."
  318.           PRINT "Reset the HC11."
  319.           CLOSE
  320.           INPUT "Hit RETURN to continue."; CR$
  321.           GOTO PickMainOption
  322.        END IF
  323. Filename2:
  324.        LOCATE 23, 1
  325.        PRINT "Or reset the HC11 then enter X to return to main menu."
  326.        LOCATE 22, 1
  327.        INPUT "Enter file to be verified against PROM"; Filename$
  328.        IF Filename$ = "" THEN GOTO Filename2
  329.        IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
  330.        IF DeBugChoice$ = "5" THEN
  331.           GOSUB CheckFile
  332.           GOSUB CompareFile
  333.           GOTO Verf
  334.        END IF
  335.     END IF
  336.     GOSUB CheckFile
  337.     GOSUB SendFile
  338. Verf:
  339.     VerifyFirstOnly = 0: SentValue = 0: CheckSum = 0
  340.     CLS
  341.     LOCATE 1, 1
  342.     PRINT "Polling boards for verification."
  343.     CLOSE
  344.     GOSUB PollAfterBootLoad
  345.     CLS
  346.     PRINT "Board Status:"
  347.     PRINT
  348.     FOR I = 1 TO 8
  349.     PRINT "Board "; I - 1
  350.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  351.     IF GoodBoard(I) = 1 THEN PRINT "Part verified correctly."
  352.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  353.     IF GoodBoard(I) = 3 THEN PRINT "Part does NOT verify."
  354.     NEXT I
  355.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  356.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  357.     PRINT #1, CHR$(value);
  358.     CLOSE #1
  359.     PRINT : PRINT
  360.     INPUT "Hit ENTER to continue"; CR$
  361.     RETURN
  362.  
  363. CheckConnection:
  364.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  365.     CheckSum = 0: Verify = 0
  366.     Filename$ = "GConE9.MX"
  367.     CLS
  368.     LOCATE 1, 1
  369.     PRINT "Downloading code into RAM to check connection."
  370.     GOSUB CheckFile
  371.     GOSUB ConvertFile4RAM
  372.     GOSUB RAMSendFile
  373.     GOSUB PollAfterBootLoad
  374.     CLS
  375.     PRINT "Board Status:"
  376.     PRINT
  377.     FOR I = 1 TO 8
  378.     PRINT "Board "; I - 1
  379.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  380.     IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
  381.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
  382.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
  383.     NEXT I
  384.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  385.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  386.     PRINT #1, CHR$(value);
  387.     CLOSE #1
  388.     PRINT : PRINT
  389.     INPUT "Hit ENTER to continue"; CR$
  390.     RETURN
  391.  
  392. TestWithRAM:
  393.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  394.     CheckSum = 0: Verify = 0
  395.     Filename$ = "LEDE9.MX"
  396.     CLS
  397.     LOCATE 1, 1
  398.     PRINT "Downloading code into RAM for Board Test."
  399.     GOSUB CheckFile
  400.     GOSUB ConvertFile4RAM
  401.     GOSUB RAMSendFile
  402.     CLS
  403.     PRINT "Red LED Should blink 16 times."
  404.     INPUT "Hit RETURN when complete."; CR$
  405.     RETURN
  406.  
  407. TestProgProm:
  408.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  409.     CheckSum = 5: Verify = 0
  410.     Filename$ = "GPROGE9.MX"
  411.     CLS
  412.     LOCATE 1, 1
  413.     PRINT "Downloading code into RAM for PROM programming."
  414.     GOSUB CheckFile
  415.     GOSUB ConvertFile4RAM
  416.     GOSUB RAMSendFile
  417.     GOSUB PollAfterBootLoad
  418.  
  419.     CLS
  420.     PRINT "Board Status:"
  421.     PRINT
  422.     FOR I = 1 TO 8
  423.     PRINT "Board "; I - 1
  424.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  425.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  426.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  427.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  428.     NEXT I
  429.     BootLoad = 0
  430.     LOCATE 21, 1
  431.     PRINT "RAM ready to program PROM."
  432.     Filename$ = "E9Blink.MX"
  433.     GOSUB CheckFile
  434.     GOSUB SendFile
  435.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  436.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  437.     PRINT #1, CHR$(value);
  438.     CLOSE #1
  439.     CLS
  440.     CLOSE #2
  441.     TempFileName$ = Filename$
  442.     GOSUB VerProm
  443.  
  444.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  445.     CheckSum = 0: Verify = 0
  446.     Filename$ = "GJMPE9.MX"
  447.     CLS
  448.     LOCATE 1, 1
  449.     PRINT "Downloading code into RAM to jump to EPROM."
  450.     GOSUB CheckFile
  451.     GOSUB ConvertFile4RAM
  452.     GOSUB RAMSendFile
  453.     GOSUB PollAfterBootLoad
  454.     CLS
  455.     PRINT "Board Status:"
  456.     PRINT
  457.     FOR I = 1 TO 8
  458.     PRINT "Board "; I - 1
  459.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  460.     IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
  461.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
  462.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
  463.     NEXT I
  464.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  465.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  466.     PRINT #1, CHR$(value);
  467.     CLOSE #1
  468.  
  469.     PRINT
  470.     PRINT "PROM has been programmed."
  471.     PRINT "The LED's should blink 16 times."
  472.     INPUT "Hit RETURN when finished"; CR$
  473.     RETURN
  474.  
  475. TestProgEEProm:
  476.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  477.     CheckSum = 5: Verify = 0
  478.     Filename$ = "GPROGE9.MX"
  479.     CLS
  480.     LOCATE 1, 1
  481.     PRINT "Downloading code into RAM for PROM programming."
  482.     GOSUB CheckFile
  483.     GOSUB ConvertFile4RAM
  484.     GOSUB RAMSendFile
  485.     GOSUB PollAfterBootLoad
  486.  
  487.     CLS
  488.     PRINT "Board Status:"
  489.     PRINT
  490.     FOR I = 1 TO 8
  491.     PRINT "Board "; I - 1
  492.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  493.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  494.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  495.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  496.     NEXT I
  497.     BootLoad = 0
  498.     LOCATE 21, 1
  499.     PRINT "RAM ready to program PROM."
  500.     Filename$ = "E9E2Blnk.MX"
  501.     GOSUB CheckFile
  502.     GOSUB SendFile
  503.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  504.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  505.     PRINT #1, CHR$(value);
  506.     CLOSE #1
  507.     CLS
  508.     CLOSE #2
  509.     TempFileName$ = Filename$
  510.     GOSUB VerProm
  511.  
  512.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  513.     CheckSum = 0: Verify = 0
  514.     Filename$ = "GJMPEE9.MX"
  515.     CLS
  516.     LOCATE 1, 1
  517.     PRINT "Downloading code into RAM to jump to EPROM."
  518.     GOSUB CheckFile
  519.     GOSUB ConvertFile4RAM
  520.     GOSUB RAMSendFile
  521.     GOSUB PollAfterBootLoad
  522.     CLS
  523.     PRINT "Board Status:"
  524.     PRINT
  525.     FOR I = 1 TO 8
  526.     PRINT "Board "; I - 1
  527.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  528.     IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
  529.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
  530.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
  531.     NEXT I
  532.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  533.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  534.     PRINT #1, CHR$(value);
  535.     CLOSE #1
  536.  
  537.     PRINT
  538.     PRINT "PROM has been programmed."
  539.     PRINT "The LED's should blink 16 times."
  540.     INPUT "Hit RETURN when finished"; CR$
  541.     RETURN
  542.  
  543.  
  544. '*****************************************************************************
  545. '*****************************************************************************
  546. '*                                                                           *
  547. '*                      Level two  subroutines                               *
  548. '*                                                                           *
  549. '*****************************************************************************
  550. '*****************************************************************************
  551.  
  552. '*****************************************************************************
  553. '*                                                                           *
  554. '*        This routine checks for non S-records in files                     *
  555. '*                                                                           *
  556. '*****************************************************************************
  557.  
  558. CheckFile:
  559.     CLS
  560.     LOCATE 10, 10
  561.     PRINT "Checking the S19 file for validity and address ranges."
  562.     RecordCount = 0
  563.     RAMAddressLow = 0: RAMAddressHigh = 511
  564.     EEPromAddressLow = 46592: EEPromAddressHigh = 47103
  565.     EPromAddressLow = 53248: EPromAddressHigh = 65535
  566.     OPEN Filename$ FOR INPUT AS #2
  567. NoS1Records:
  568.     INPUT #2, record$
  569.     IF LEFT$(record$, 2) = "S0" THEN GOTO NoS1Records
  570.     IF LEFT$(record$, 2) = "S1" THEN
  571.         RecordCount = RecordCount + 1
  572.         Nibble$ = MID$(record$, 3, 1)
  573.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  574.         IF Nibble = -1 THEN
  575.            CLS
  576.            PRINT "Error converting number1 to hex."
  577.            PRINT "Reset the HC11."
  578.            CLOSE
  579.            INPUT "Hit RETURN to continue."; CR$
  580.            RETURN PickMainOption
  581.            END IF
  582.         CheckLength = Nibble * 16
  583.         Nibble$ = MID$(record$, 4, 1)
  584.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  585.         IF Nibble = -1 THEN
  586.            CLS
  587.            PRINT "Error converting number2 to hex."
  588.            PRINT "Reset the HC11."
  589.            CLOSE
  590.            INPUT "Hit RETURN to continue."; CR$
  591.            RETURN PickMainOption
  592.            END IF
  593.         CheckLength = (CheckLength + Nibble) - 4
  594.  
  595.         CheckAddress$ = MID$(record$, 5, 4)
  596.         Nibble$ = LEFT$(CheckAddress$, 1)
  597.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  598.         IF Nibble = -1 THEN
  599.            CLS
  600.            PRINT "Error converting number1 to hex."
  601.            PRINT "Reset the HC11."
  602.            CLOSE
  603.            INPUT "Hit RETURN to continue."; CR$
  604.            RETURN PickMainOption
  605.         END IF
  606.         CheckAddress = Nibble * 4096
  607.         Nibble$ = MID$(CheckAddress$, 2, 1)
  608.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  609.         IF Nibble = -1 THEN
  610.            CLS
  611.            PRINT "Error converting number2 to hex."
  612.            PRINT "Reset the HC11."
  613.            CLOSE
  614.            INPUT "Hit RETURN to continue."; CR$
  615.            RETURN PickMainOption
  616.            END IF
  617.         CheckAddress = CheckAddress + (Nibble * 256)
  618.         Nibble$ = MID$(CheckAddress$, 3, 1)
  619.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  620.         IF Nibble = -1 THEN
  621.            CLS
  622.            PRINT "Error converting number3 to hex."
  623.            PRINT "Reset the HC11."
  624.            CLOSE
  625.            INPUT "Hit RETURN to continue."; CR$
  626.            RETURN PickMainOption
  627.            END IF
  628.         CheckAddress = CheckAddress + (Nibble * 16)
  629.         Nibble$ = RIGHT$(CheckAddress$, 1)
  630.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  631.         IF Nibble = -1 THEN
  632.            CLS
  633.            PRINT "Error converting number4 to hex."
  634.            PRINT "Reset the HC11."
  635.            CLOSE
  636.            INPUT "Hit RETURN to continue."; CR$
  637.            RETURN PickMainOption
  638.            END IF
  639.         CheckAddress = CheckAddress + Nibble
  640.         IF BootLoad = 1 THEN
  641.            IF CheckAddress + CheckLength > RAMAddressHigh THEN GOTO AddressError
  642.            GOTO NoS1Records
  643.         END IF
  644.         IF CheckAddress < EEPromAddressLow THEN GOTO AddressError
  645.         IF CheckAddress + CheckLength > EEPromAddressHigh AND CheckAddress < EPromAddressLow THEN
  646.            GOTO AddressError
  647.         END IF
  648.         IF CheckAddress + CheckLength > EPromAddressHigh THEN GOTO AddressError
  649.         GOTO NoS1Records
  650.     END IF
  651.     IF LEFT$(record$, 2) = "S9" THEN
  652.        IF RecordCount = 0 THEN
  653.           CLOSE
  654.           CLS
  655.           LOCATE 12, 1
  656.           PRINT "There are no S1 records in this file."
  657.           INPUT "Hit enter to continue"; CR$
  658.           RETURN PickMainOption
  659.        ELSE
  660.           CLOSE #2
  661.           RETURN
  662.        END IF
  663.     END IF
  664.     CLOSE
  665.     CLS
  666.     LOCATE 12, 1
  667.     PRINT "This file contains one or more none S19 records."
  668.     INPUT "Hit enter to continue"; CR$
  669.     RETURN PickMainOption
  670.  
  671. AddressError:
  672. '        CLS
  673.     CLOSE
  674.     PRINT "S-record file contains address not available in this part."
  675.     PRINT "File name: "; Filename$
  676.     PRINT "Record Number "; RecordCount
  677.     PRINT "Record = "; record$
  678.     PRINT "Record start address: $"; HEX$(CheckAddress)
  679.     PRINT "Record end address: $"; HEX$(CheckAddress + CheckLength)
  680.     PRINT
  681.     PRINT "Reset the HC11."
  682.     INPUT "Hit RETURN to continue."; CR$
  683.     RETURN PickMainOption
  684.  
  685.  
  686.  
  687.  
  688. '*****************************************************************************
  689. '*                                                                           *
  690. '*    Convert from S-records for fast download to RAM using Bootloader       *
  691. '*                                                                           *
  692. '*                                                                           *
  693. '*****************************************************************************
  694. ConvertFile4RAM:
  695.     RAMLoadByte$ = CHR$(255)
  696.     RecordCount = 0
  697.     OPEN Filename$ FOR INPUT AS #2
  698. RAMNoS1Records:
  699.     INPUT #2, record$
  700.     IF LEFT$(record$, 2) = "S0" THEN GOTO RAMNoS1Records
  701.     IF LEFT$(record$, 2) = "S1" THEN
  702.        record$ = RIGHT$(record$, LEN(record$) - 6)
  703.        RecordCount = RecordCount + 1
  704. NextConvertByte:
  705.        record$ = RIGHT$(record$, LEN(record$) - 2)
  706.        IF LEN(record$) > 2 THEN
  707.           ConvertByte$ = LEFT$(record$, 2)
  708.           Nibble$ = LEFT$(ConvertByte$, 1)
  709.           Nibble = INSTR(HexConvert$, Nibble$) - 1
  710.           IF Nibble = -1 THEN
  711.          CLS
  712.          PRINT "Error converting number1 to hex"
  713.          INPUT CR$
  714.          RETURN
  715.           END IF
  716.           MSBNibble = Nibble * 16
  717.           Nibble$ = RIGHT$(ConvertByte$, 1)
  718.           Nibble = INSTR(HexConvert$, Nibble$) - 1
  719.           IF Nibble = -1 THEN
  720.          CLS
  721.          PRINT "Error converting number1 to hex"
  722.          INPUT CR$
  723.          RETURN
  724.           END IF
  725.           value = MSBNibble + Nibble
  726.           RAMLoadByte$ = RAMLoadByte$ + CHR$(value)
  727.           GOTO NextConvertByte
  728.         END IF
  729.         GOTO RAMNoS1Records
  730.     END IF
  731.     IF LEFT$(record$, 2) = "S9" THEN
  732.        IF RecordCount = 0 THEN
  733.           CLOSE
  734.           CLS
  735.           LOCATE 12, 1
  736.           PRINT "There are no S1 records in this file."
  737.           INPUT "Hit enter to continue"; CR$
  738.           RETURN PickMainOption
  739.        ELSE
  740.           CLOSE
  741.           CLS
  742.           RETURN
  743.        END IF
  744.     END IF
  745.     CLOSE
  746.     CLS
  747.     LOCATE 12, 1
  748.     PRINT "This file contains one or more none S19 records."
  749.     INPUT "Hit enter to continue"; CR$
  750.     RETURN PickMainOption
  751.  
  752. '*****************************************************************************
  753. '*                                                                           *
  754. '*              This routine programs RAM using bootloader                   *
  755. '*                                                                           *
  756. '*****************************************************************************
  757.  
  758. RAMSendFile:
  759.        LOCATE 4, 1
  760.        PRINT "Transfering control program to HC11 RAM."
  761.  
  762.     I = 0
  763.     IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  764.     IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  765.     PRINT #1, RAMLoadByte$;
  766.     CLOSE
  767.     RETURN
  768.  
  769.  
  770. '*****************************************************************************
  771. '*                                                                           *
  772. '*              This routine sends file to HC11                              *
  773. '*                                                                           *
  774. '*****************************************************************************
  775.  
  776. SendFile:
  777.     OPEN Filename$ FOR INPUT AS #2
  778.     IF BootLoad = 1 THEN
  779.        IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  780.        IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  781.        value = 255
  782.        PRINT #1, CHR$(value);
  783.     END IF
  784.     IF BootLoad = 0 THEN
  785.        IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  786.        IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  787.     END IF
  788.     BytesSent = 0
  789.     RecordsSent = 0
  790.     CLS
  791.     LOCATE 10, 10
  792.     PRINT "Number of records to be sent: "; RecordCount
  793.     LOCATE 11, 10
  794.     PRINT "Records sent: "
  795. SendFileLength:
  796.        IF BootLoad = 0 THEN
  797.           TransErrorCode = 0
  798.           value = TalkAddress
  799.           GOSUB TRANSxVALUE
  800.           VerifyFirstOnly = 1
  801.           SentValue = value
  802.           GOSUB CheckRecValue
  803.           IF TransErrorCode <> 1 THEN
  804.          LOCATE 20, 1
  805.          PRINT "Verification of talk address failed."
  806.          PRINT "Reset the HC11."
  807.          CLOSE
  808.          INPUT "Hit RETURN to continue."; CR$
  809.          RETURN PickMainOption
  810.           END IF
  811.        END IF
  812. GetRecord:
  813.     INPUT #2, record$
  814.     RecordType$ = LEFT$(record$, 2)
  815.     IF RecordType$ = "S0" THEN
  816.        GOTO GetRecord
  817.     END IF
  818.     IF RecordType$ = "S1" THEN
  819.        RecordsSent = RecordsSent + 1
  820.        LOCATE 11, 24
  821.        PRINT RecordsSent
  822.        RecordLength$ = MID$(record$, 3, 2)
  823.        RecordAddress$ = MID$(record$, 5, 4)
  824.        record$ = RIGHT$(record$, LEN(record$) - 8)
  825. ParseAndSend:
  826.        IF BootLoad = 1 THEN
  827.           TransErrorCode = 0
  828.           IF LEN(record$) > 2 THEN
  829.          TransHexValue$ = LEFT$(record$, 2)
  830.          record$ = RIGHT$(record$, LEN(record$) - 2)
  831.          GOSUB SENDxVALUE
  832.          IF TransErrorCode <> 1 THEN
  833.             LOCATE 20, 1
  834.             PRINT "Verification failed."
  835.             PRINT "Successfully sent "; RecordsSent; " S1 records."
  836.             PRINT "Reset the HC11."
  837.             CLOSE
  838.             INPUT "Hit RETURN to continue."; CR$
  839.             RETURN PickMainOption
  840.          ELSE
  841.             GOTO ParseAndSend
  842.          END IF
  843.           ELSE
  844.          GOTO GetRecord
  845.           END IF
  846.        ELSE
  847. SendAddress:
  848.           TransErrorCode = 0
  849.           TransHexValue$ = LEFT$(RecordAddress$, 2)
  850.           GOSUB SENDxVALUE
  851.           VerifyFirstOnly = 1
  852.           SentValue = value
  853.           GOSUB CheckRecValue
  854.           IF TransErrorCode <> 1 THEN
  855.          LOCATE 20, 1
  856.          PRINT "Verification of MSB of address failed."
  857.          PRINT "Reset the HC11."
  858.          CLOSE
  859.          INPUT "Hit RETURN to continue."; CR$
  860.          RETURN PickMainOption
  861.           END IF
  862.           TransHexValue$ = RIGHT$(RecordAddress$, 2)
  863.           GOSUB SENDxVALUE
  864.           VerifyFirstOnly = 1
  865.           SentValue = value
  866.           GOSUB CheckRecValue
  867.           IF TransErrorCode <> 1 THEN
  868.          LOCATE 20, 1
  869.          PRINT "Verification of LSB of address failed."
  870.          PRINT "Reset the HC11."
  871.          CLOSE
  872.          INPUT "Hit RETURN to continue."; CR$
  873.          RETURN PickMainOption
  874.           END IF
  875. SendRecordLength:
  876.           TransHexValue$ = RecordLength$
  877.           GOSUB SENDxVALUE
  878.           VerifyFirstOnly = 1
  879.           SentValue = value
  880.           GOSUB CheckRecValue
  881.           IF TransErrorCode <> 1 THEN
  882.          LOCATE 20, 1
  883.          PRINT "Verification of record length failed."
  884.          PRINT "Reset the HC11."
  885.          CLOSE
  886.          PRINT "Hit RETURN to continue,"; CR$
  887.          RETURN PickMainOption
  888.           END IF
  889. SendData:
  890.           IF LEN(record$) > 2 THEN
  891.          TransHexValue$ = LEFT$(record$, 2)
  892.          record$ = RIGHT$(record$, LEN(record$) - 2)
  893.          GOSUB SENDxVALUE
  894.          VerifyFirstOnly = 1
  895.          SentValue = value
  896.          GOSUB CheckRecValue
  897.          IF TransErrorCode <> 1 THEN
  898.             LOCATE 20, 1
  899.             PRINT "Verification failed."
  900. '                    PRINT "Successfully sent "; RecordsSent; " S1 records."
  901. '                    INPUT "Reset the HC11 then enter RETURN to go to main menu.";CR$
  902. '                    GOTO PickMainOption
  903.             GOTO SendData
  904.          ELSE
  905.             GOTO SendData
  906.          END IF
  907.           ELSE
  908.          FirstRecordSent = 1
  909.          GOTO GetRecord
  910.           END IF
  911.        END IF
  912.     END IF
  913.     IF RecordType$ = "S9" THEN
  914.        TransErrorCode = 0
  915.        TransHexValue$ = "00"
  916.        GOSUB SENDxVALUE
  917.        VerifyFirstOnly = 1
  918.        SentValue = value
  919.        GOSUB CheckRecValue
  920.        IF TransErrorCode <> 1 THEN
  921.           LOCATE 20, 1
  922.           PRINT "Verification of end of file1 failed."
  923.           PRINT "Reset the HC11."
  924.           CLOSE
  925.           INPUT "Hit RETURN to continue."; CR$
  926.           RETURN PickMainOption
  927.        END IF
  928.        TransErrorCode = 0
  929.        TransHexValue$ = "00"
  930.        GOSUB SENDxVALUE
  931.        VerifyFirstOnly = 1
  932.        SentValue = value
  933.        GOSUB CheckRecValue
  934.        IF TransErrorCode <> 1 THEN
  935.           LOCATE 20, 1
  936.           PRINT "Verification of end of file2 failed."
  937.           PRINT "Reset the HC11."
  938.           CLOSE
  939.           INPUT "Hit RETURN to continue."; CR$
  940.           RETURN PickMainOption
  941.        END IF
  942.        TransErrorCode = 0
  943.        TransHexValue$ = "00"
  944.        GOSUB SENDxVALUE
  945.        VerifyFirstOnly = 1
  946.        SentValue = value
  947.        GOSUB CheckRecValue
  948.        IF TransErrorCode <> 1 THEN
  949.           LOCATE 20, 1
  950.           PRINT "Verification of end of file3 failed."
  951.           PRINT "Reset the HC11."
  952.           CLOSE
  953.           INPUT "Hit RETURN to continue."; CR$
  954.           RETURN PickMainOption
  955.        END IF
  956.        CLOSE #1
  957.        CLOSE #2
  958.        RETURN
  959.     ELSE
  960.        PRINT "A Non S19 record has been encountered. Abort Download."
  961.        RETURN PickMainOption
  962.     END IF
  963.  
  964.  
  965.  
  966. '*****************************************************************************
  967. '*                                                                           *
  968. '*              This routine compares a file to HC11                         *
  969. '*                                                                           *
  970. '*****************************************************************************
  971.  
  972. CompareFile:
  973.     CLS
  974.     LOCATE 1, 30
  975.     PRINT "File Comparison"
  976.     LOCATE 3, 1
  977.     INPUT "Which board to compare"; TalkAddress
  978.     LOCATE 4, 1
  979.     PRINT "File to compare with: "; Filename$
  980.     OPEN Filename$ FOR INPUT AS #2
  981.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  982.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  983.     BytesSent = 0
  984.     RecordsSent = 0
  985.     LOCATE 5, 1
  986.     PRINT "Number of records to be sent: "; RecordCount
  987.     LOCATE 6, 1
  988.     PRINT "Records sent: "
  989. SendCFileLength:
  990.     TransErrorCode = 0
  991.     value = TalkAddress
  992.     GOSUB TRANSxVALUE
  993.     VerifyFirstOnly = 1
  994.     SentValue = value
  995.     GOSUB CheckRecValue
  996.     IF TransErrorCode <> 1 THEN
  997.        LOCATE 20, 1
  998.        PRINT "Verification of talk address failed."
  999.        PRINT "Reset the HC11."
  1000.        CLOSE
  1001.        INPUT "Hit RETURN to continue."; CR$
  1002.        RETURN PickMainOption
  1003.     END IF
  1004. GetCRecord:
  1005.     INPUT #2, record$
  1006.     RecordType$ = LEFT$(record$, 2)
  1007.     IF RecordType$ = "S0" THEN
  1008.        GOTO GetCRecord
  1009.     END IF
  1010.     IF RecordType$ = "S1" THEN
  1011.        LOCATE 7, 1
  1012.        PRINT "Transfering following S1 record."
  1013.        LOCATE 8, 1
  1014.        PRINT "                                                                    "
  1015.        LOCATE 8, 1
  1016.        PRINT MID$(record$, 5, LEN(record$) - 6)
  1017.        RecordsSent = RecordsSent + 1
  1018.        LOCATE 6, 15
  1019.        PRINT RecordsSent
  1020.        RecordLength$ = MID$(record$, 3, 2)
  1021.        RecordAddress$ = MID$(record$, 5, 4)
  1022.        record$ = RIGHT$(record$, LEN(record$) - 8)
  1023. ParseCAndSend:
  1024. SendCAddress:
  1025.        TransErrorCode = 0
  1026.        TransHexValue$ = LEFT$(RecordAddress$, 2)
  1027.        MSB$ = LEFT$(RecordAddress$, 2)
  1028.        GOSUB SENDxVALUE
  1029.        VerifyFirstOnly = 1
  1030.        SentValue = value
  1031.        GOSUB CheckRecValue
  1032.        IF TransErrorCode <> 1 THEN
  1033.           LOCATE 20, 1
  1034.           PRINT "Verification of MSB of address failed."
  1035.           PRINT "Reset the HC11"
  1036.           CLOSE
  1037.           INPUT "Hit RETURN to continue."; CR$
  1038.           RETURN PickMainOption
  1039.        END IF
  1040.        TransHexValue$ = RIGHT$(RecordAddress$, 2)
  1041.        LSB$ = RIGHT$(RecordAddress$, 2)
  1042.        GOSUB SENDxVALUE
  1043.        VerifyFirstOnly = 1
  1044.        SentValue = value
  1045.        GOSUB CheckRecValue
  1046.        IF TransErrorCode <> 1 THEN
  1047.           LOCATE 20, 1
  1048.           PRINT "Verification of LSB of address failed."
  1049.           PRINT "Reset the HC11"
  1050.           CLOSE
  1051.           INPUT "Hit RETURN to continue."; CR$
  1052.           RETURN PickMainOption
  1053.        ELSE
  1054.           PrintRecord$ = MSB$ + LSB$
  1055.           LOCATE 10, 1
  1056.           PRINT "                                                         "
  1057.           LOCATE 10, 1
  1058.           PRINT PrintRecord$
  1059.        END IF
  1060. SendCRecordLength:
  1061.        TransHexValue$ = RecordLength$
  1062.        GOSUB SENDxVALUE
  1063.        VerifyFirstOnly = 1
  1064.        SentValue = value
  1065.        GOSUB CheckRecValue
  1066.        IF TransErrorCode <> 1 THEN
  1067.           LOCATE 20, 1
  1068.           PRINT "Verification of record length failed."
  1069.           PRINT "Reset the HC11"
  1070.           CLOSE
  1071.           PRINT "Hit RETURN to continue,"; CR$
  1072.           RETURN PickMainOption
  1073.        END IF
  1074. SendCData:
  1075.        IF LEN(record$) > 2 THEN
  1076.           TransHexValue$ = LEFT$(record$, 2)
  1077.           record$ = RIGHT$(record$, LEN(record$) - 2)
  1078.           GOSUB SENDxVALUE
  1079.           VerifyFirstOnly = 1
  1080.           SentValue = value
  1081.           GOSUB CheckRecValue
  1082.           GOSUB Back2Hex
  1083.           PrintRecord$ = PrintRecord$ + Byte$
  1084.           LOCATE 10, 1
  1085.           PRINT "                                                                    "
  1086.           LOCATE 10, 1
  1087.           PRINT PrintRecord$
  1088.           IF TransErrorCode <> 1 THEN
  1089.          LOCATE 14, 1
  1090.          PRINT "Verification failed."
  1091.          INPUT "Hit RETURN to continue."; CR$
  1092.          GOTO SendCData
  1093.           ELSE
  1094.          GOTO SendCData
  1095.           END IF
  1096.        ELSE
  1097.           FirstRecordSent = 1
  1098.           GOTO GetCRecord
  1099.        END IF
  1100.     END IF
  1101.     IF RecordType$ = "S9" THEN
  1102.        TransErrorCode = 0
  1103.        TransHexValue$ = "00"
  1104.        GOSUB SENDxVALUE
  1105.        VerifyFirstOnly = 1
  1106.        SentValue = value
  1107.        GOSUB CheckRecValue
  1108.        IF TransErrorCode <> 1 THEN
  1109.           LOCATE 20, 1
  1110.           PRINT "Verification of end of file1 failed."
  1111.           PRINT "Reset the HC11."
  1112.           CLOSE
  1113.           INPUT "Hit RETURN to continue."; CR$
  1114.           RETURN PickMainOption
  1115.        END IF
  1116.        TransErrorCode = 0
  1117.        TransHexValue$ = "00"
  1118.        GOSUB SENDxVALUE
  1119.        VerifyFirstOnly = 1
  1120.        SentValue = value
  1121.        GOSUB CheckRecValue
  1122.        IF TransErrorCode <> 1 THEN
  1123.           LOCATE 20, 1
  1124.           PRINT "Verification of end of file2 failed."
  1125.           PRINT "Reset the HC11."
  1126.           CLOSE
  1127.           INPUT "Hit RETURN to continue."; CR$
  1128.           RETURN PickMainOption
  1129.        END IF
  1130.        TransErrorCode = 0
  1131.        TransHexValue$ = "00"
  1132.        GOSUB SENDxVALUE
  1133.        VerifyFirstOnly = 1
  1134.        SentValue = value
  1135.        GOSUB CheckRecValue
  1136.        IF TransErrorCode <> 1 THEN
  1137.           LOCATE 20, 1
  1138.           PRINT "Verification of end of file3 failed."
  1139.           PRINT "Reset the HC11."
  1140.           INPUT "Hit RETURN to continue."; CR$
  1141.           RETURN PickMainOption
  1142.        END IF
  1143.        CLOSE #1
  1144.        CLOSE #2
  1145.        RETURN
  1146.     ELSE
  1147.        LOCATE 20, 1
  1148.        PRINT "A Non S19 record has been encountered. Abort Download."
  1149.        PRINT "Reset the HC11."
  1150.        CLOSE
  1151.        INPUT "Hit RETURN to continue."; CR$
  1152.        RETURN PickMainOption
  1153.     END IF
  1154.  
  1155.  
  1156.  
  1157.  
  1158. '*****************************************************************************
  1159. '*                                                                           *
  1160. '*                                                                           *
  1161. '*  Call into this routine with parameter TransHexValue = string of two      *
  1162. '*     characters consisting of the byte in hex to be sent.                  *
  1163. '*  Routine also increments BytesSent                                        *
  1164. '*                                                                           *
  1165. '*****************************************************************************
  1166. SENDxVALUE:
  1167. TESTxCOUNT = 1
  1168. FirstByteLoop = 0
  1169. ConvertValue:
  1170. Nibble$ = LEFT$(TransHexValue$, 1)
  1171. Nibble = INSTR(HexConvert$, Nibble$) - 1
  1172. IF Nibble = -1 THEN
  1173.    CLS
  1174.    PRINT "Error converting number1 to hex."
  1175.    PRINT "Reset the HC11."
  1176.    CLOSE
  1177.    INPUT "Hit RETURN to continue."; CR$
  1178.    RETURN PickMainOption
  1179. END IF
  1180. MSBNibble = Nibble * 16
  1181. Nibble$ = RIGHT$(TransHexValue$, 1)
  1182. Nibble = INSTR(HexConvert$, Nibble$) - 1
  1183. IF Nibble = -1 THEN
  1184.    CLS
  1185.    PRINT "Error converting number2 to hex."
  1186.    PRINT "Reset the HC11."
  1187.    CLOSE
  1188.    INPUT "Hit RETURN to continue."; CR$
  1189.    RETURN PickMainOption
  1190. END IF
  1191. value = MSBNibble + Nibble
  1192. TRANSxVALUE:
  1193. PRINT #1, CHR$(value);
  1194. TransErrorCode = 1
  1195. RETURN
  1196.  
  1197. '*****************************************************************************
  1198. '*                                                                           *
  1199. '*                                                                           *
  1200. '*                     Converts Val1 back to Hex                             *
  1201. '*                                                                           *
  1202. '*                                                                           *
  1203. '*****************************************************************************
  1204.  
  1205. Back2Hex:
  1206. High = INT(VAL1 \ 16)
  1207. High$ = HEX$(High)
  1208. Low = VAL1 - (High * 16)
  1209. Low$ = HEX$(Low)
  1210. Byte$ = High$ + Low$
  1211. RETURN
  1212.  
  1213.  
  1214. '*****************************************************************************
  1215. '*                                                                           *
  1216. '*                                                                           *
  1217. '*             Compares rec value with variable "Value"                      *
  1218. '*                                                                           *
  1219. '*                                                                           *
  1220. '*****************************************************************************
  1221. CheckRecValue:
  1222. TESTxCOUNT = 0
  1223. TESTxLOOP1:
  1224. IF NOT EOF(1) THEN
  1225.     INP$ = INPUT$(LOC(1), #1)
  1226.     VAL1 = ASC(INP$)
  1227.     IF VAL1 = value THEN
  1228.         TransErrorCode = 1
  1229.         BytesSent = BytesSent + 1
  1230.         RETURN
  1231.     ELSE
  1232.         LOCATE 15, 1
  1233.         PRINT "Value Returned Wrong"
  1234.         PRINT "Value Sent = "; value
  1235.         PRINT "Value Received from HC11 ="; VAL1
  1236.         IF Debug = 1 THEN
  1237.            INPUT "Hit Return to End"; CR$
  1238.         END IF
  1239.         LOCATE 13, 1
  1240.         PRINT "                                    "
  1241.         PRINT "                                    "
  1242.         PRINT "                                    "
  1243.         PRINT "                                    "
  1244.         PRINT "                                    "
  1245.         PRINT "                                    "
  1246.         TransErrorCode = 0
  1247.         RETURN
  1248.     END IF
  1249. ELSE
  1250.     TESTxCOUNT = TESTxCOUNT + 1
  1251.     IF TESTxCOUNT > ResponseTime THEN
  1252.         PRINT "HC11 NOT RESPONDING TO VALUE"
  1253.         PRINT "                                    "
  1254.         PRINT "                                    "
  1255.         TransErrorCode = 0
  1256.         RETURN
  1257.     ELSE
  1258.         GOTO TESTxLOOP1
  1259.     END IF
  1260. END IF
  1261.  
  1262.  
  1263. '*****************************************************************************
  1264. '*                                                                           *
  1265. '*                                                                           *
  1266. '*               Check that all parts got boot code correctly                *
  1267. '*                                                                           *
  1268. '*                                                                           *
  1269. '*****************************************************************************
  1270.  
  1271. PollAfterBootLoad:
  1272. IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  1273. IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  1274. BoardAddress = 0
  1275. TalkAddress = 8
  1276. FOR I = 1 TO 9
  1277.   GoodBoard(I) = 1
  1278.   value = BoardAddress
  1279.   LOCATE 10, 1
  1280.   PRINT "Checking RAM download."
  1281.   LOCATE 12, 1
  1282.   PRINT "Sending board address: "; BoardAddress
  1283.   GOSUB TRANSxVALUE
  1284.   IF BoardAddress = 8 THEN GOTO NextBootPoll
  1285.   GOSUB CheckRecValue
  1286.   IF TransErrorCode <> 1 THEN
  1287.      GoodBoard(I) = 2
  1288.      GOTO NextBootPoll
  1289.   END IF
  1290.   TalkAddress = BoardAddress
  1291.   LOCATE 14, 1
  1292.   PRINT "Verifying Checksum"
  1293.   GOSUB TRANSxVALUE
  1294.   value = CheckSum
  1295.   GOSUB CheckRecValue
  1296.   IF TransErrorCode <> 1 THEN
  1297.      GoodBoard(I) = 3
  1298.      GOTO NextBootPoll
  1299.   END IF
  1300. NextBootPoll:
  1301.   BoardAddress = BoardAddress + 1
  1302. NEXT I
  1303. CLOSE #1
  1304. RETURN
  1305. '*
  1306. '*
  1307. '*
  1308. '*****************************************************************************
  1309. '*****************************************************************************
  1310. '*
  1311. '*
  1312. ErrorTrap:
  1313. CLS
  1314. PRINT "File Name does not exist."
  1315. PRINT
  1316. PRINT "Enter another file name or"
  1317. INPUT "Reset HC11 then enter RETURN to return to main menu."; Filename$
  1318. IF Filename$ = "" THEN
  1319.    RESUME PickMainOption
  1320. ELSE
  1321.    RESUME
  1322. END IF
  1323. '*
  1324. '*
  1325. '*
  1326. END
  1327. '
  1328. '
  1329. '
  1330. '
  1331. '
  1332. '***************************************************************************
  1333. '***************                                             ***************
  1334. '***************                  END ROUTINE                ***************
  1335. '***************                                             ***************
  1336. '***************************************************************************
  1337.  
  1338.  
  1339.  
  1340.